//
//  IGBaseRequest+IGTokenInvalidMethod.m
//  jingdongfang
//
//  Created by BOE on 2017/8/10.
//  Copyright © 2017年 ZhiYu Hao. All rights reserved.
//

#import "IGBaseRequest+IGTokenInvalidMethod.h"
#import "AppDelegate.h"

@implementation IGBaseRequest (IGTokenInvalidMethod)
    
- (void)operationWithResponseObject:(IGBaseResp *)resp
                              error:(NSError *)error
                      completeBlock:(IGRequestCompletionBlock)completeBlock {
    if (resp
        && [resp.resHeader.code isEqualToString:@"com004"]) { //Token失效
        [(AppDelegate *)[UIApplication sharedApplication].delegate configLoginVC];
        [self presentMessageTips:NSLocalizedString(@"Login expired,Please login again.", nil)];
    } else if(resp && [self showLogicErrorToast]) {           //业务逻辑错误
        [self presentMessageTips:resp.resHeader.message];
    } else if([error.domain isEqualToString:@"Model Exception"]){//本地异常
        [self dismissLoading];
    } else {//网络异常等
        [self dismissLoading];
    }
    completeBlock(nil, error);
}
    
@end
